package ai.leinao.alarm.service;

import ai.leinao.alarm.domain.AlarmRule;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * description
 *
 * @author zhong.wang
 * @date 2025/9/8
 **/
@Service
public class AlarmRuleService {

    public List<AlarmRule> getAlarmRules(){
        List<AlarmRule> result = new ArrayList<>();
        AlarmRule rule = AlarmRule.builder()
                .name("rule1")
                .type("over-value")
                .expression("deviceModelId == 123 && temperature >= 30 && temperature < 40")
                .alarmLevel("p1")
                .build();
        result.add(rule);
        AlarmRule rule2 = AlarmRule.builder()
                .name("rule2")
                .type("over-value")
                .expression("deviceModelId == 123 && temperature >= 40 && temperature <50")
                .alarmLevel("p2")
                .build();
        result.add(rule2);
        AlarmRule rule3 = AlarmRule.builder()
                .name("rule3")
                .type("over-value")
                .expression("deviceModelId == 123 && temperature < 70 && temperature >=50")
                .alarmLevel("p3")
                .build();
        result.add(rule3);
        return result;
    }
}
